import QtQuick 2.0
import QtGraphicalEffects 1.0

// 最大化、最小化、退出
Item {
    id: zoomRect

    Row {
        id: miniRow
        anchors.verticalCenter: parent.verticalCenter
        anchors.right: parent.right
        anchors.rightMargin: 26
        spacing: 15
        Image {
            id: miniImg
            width: zoomRect.height / 2
            height: zoomRect.height / 2
            anchors.verticalCenter: parent.verticalCenter
            source: "qrc:/img/Resources/title/mini.png"
            // 图片高亮
            layer.enabled: false
            layer.effect: ColorOverlay {
                source: miniImg
                color: "white"
            }
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    miniImg.layer.enabled = true
                }
                onExited: {
                    miniImg.layer.enabled = false
                }
            }
        }

        // 最小化
        Rectangle {
            id: miniRect
            width: 20
            height: 2
            anchors.verticalCenter: parent.verticalCenter
            color: "#75777f"
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    miniRect.color = "white"
                }
                onExited: {
                    miniRect.color = "#75777f"
                }
                onClicked: {
                    window.showMinimized()
                }
            }
        }

        // 最大化
        Rectangle {
            id: maxRect
            width: 20
            height: width
            radius: 2
            border.width: 2
            color: "transparent"
            border.color: "#75777f"
            anchors.verticalCenter: parent.verticalCenter
            property bool maxFlag: false
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    maxRect.border.color = "white"
                }
                onExited: {
                    maxRect.border.color = "#75777f"
                }
                onClicked: {
                    if (maxRect.maxFlag) {
                        window.showNormal()
                        maxRect.maxFlag = false;
                    } else {
                        window.showMaximized()
                        maxRect.maxFlag = true;
                    }
                }
            }
        }

        // 关闭
        Image {
            id: closeImg
            width: zoomRect.height / 2
            height: zoomRect.height / 2
            anchors.verticalCenter: parent.verticalCenter
            source: "qrc:/img/Resources/title/close.png"
            // 图片高亮
            layer.enabled: false
            layer.effect: ColorOverlay {
                source: closeImg
                color: "white"
            }
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    closeImg.layer.enabled = true
                }
                onExited: {
                    closeImg.layer.enabled = false
                }
                onClicked: {
                    Qt.quit()
                }
            }
        }
    }
}

